<?php 
   $criteria = new CDbCriteria();
   $criteria->offset = 0;
   $criteria->limit = 4;
   $criteria->group = 'ban_position';
   $criteria->order = 'ban_id DESC'; 
   $criteria->addCondition('ban_active = 1');
   $banners = Banner::model()->findAll($criteria);
   foreach($banners as $banner){
      switch($banner->ban_position){
         case 1:
            $banner_top = $banner->ban_image;
            $url_top = $banner->ban_url;
            break;
         case 2:
            $banner_right = $banner->ban_image;
            $url_right = $banner->ban_url;
            break;
         case 3:
            $banner_bottom = $banner->ban_image;
            $url_bottom = $banner->ban_url;
            break;
         case 4:
            $banner_left = $banner->ban_image;
            $url_left = $banner->ban_url;
            break;
         
      }
   }
?>
<?php if(isset($banner_left)){?>
<div class="banner-left fixed banner-ver">
   <a href="<?php echo $url_left?>">
      <img src="<?php echo Yii::app()->params['path_image_banner'].$banner_left?>" />
   </a>
</div>
<?php }?>
<?php if(isset($banner_right)){?>
   <div class="banner-right fixed banner-ver">
      <a href="<?php echo $url_right?>">
         <img src="<?php echo Yii::app()->params['path_image_banner'].$banner_right?>" />
      </a>
   </div>
<?php }?>

<div class="container relative">
   <ul class="login">
      <?php if(Yii::app()->user->id != null){
         $member = Member::model()->findByPk(Yii::app()->user->id);
         ?>
         <li><a href="/member"><?php echo $member->MemberName?></a></li>
         <li><a href="/site/logout">Đăng xuất</a></li>
      <?php }else{?>
         <li><a href="/dang-nhap">Đăng nhập</a></li>
         <li><a href="/dang-ky">Đăng ký</a></li>
      <?php }?>
   </ul>
   <div class="clear"></div>
   <div id="logo" class="absolute">
      <a href="/">
         <img alt="logo" src="<?php echo Yii::app()->request->baseUrl;?>/images/logo-haiha.png" />
      </a>
   </div>
   <?php if(isset($banner_top)){?>
      <div class="banner banner-top">
         <a href="#">
            <img src="<?php echo Yii::app()->params['path_image_banner'].$banner_top?>" />
         </a>
      </div>
   <?php }?>
   <div class="right">
      <ul>
         <li class="relative">
            <i class="sprite icon-phone absolute"></i>
            <a href="tel: 0934485546">093 448 5546</a>
         </li>
         <li class="relative">
            <i class="sprite icon-mail absolute"></i>
            <a href="maitol:info@haihaland.vn">info@haihaland.vn</a>
         </li>
      </ul>
   </div>
   <div class="">
      <a></a>
   </div>
   <div id="main-menu" class="absolute">
      <ul class="menu-level-1">
         <li class="relative icon-home">
            <a href="/">
               <img src="<?php echo Yii::app()->request->baseUrl;?>/images/icon-home.png" />
            </a>
         </li>
         <li>
            <a class="<?php if($this->id == 'introduction') echo 'active'?>" href="/gioi-thieu">Giới thiệu</a>
         </li>
         <li>
            <a class="<?php if($this->id == 'category' && $_GET['id'] == 35) echo 'active'?>" href="/nha-dat-ban-35">Nhà đất bán</a>
         </li>
         <li>
            <a class="<?php if($this->id == 'category' && $_GET['id'] == 42) echo 'active'?>" href="/nha-dat-cho-thue-42">Nhà đất cho thuê</a>
         </li>
         <li>
            <a class="<?php if($this->id == 'news' && $this->action->id == 'geomancy') echo 'active'?>" href="/phong-thuy">Phong thủy</a>
         </li>
         <li>
            <a class="<?php if($this->id == 'news' && $this->action->id == 'project') echo 'active'?>" href="/du-an-da-trien-khai">Dự án</a>
         </li>
         <li>
            <a class="<?php if($this->id == 'news' && $this->action->id == 'index') echo 'active'?>" href="/tin-tuc">Tin tức</a>
         </li>
         <li>
            <a class="<?php if($this->id == 'question') echo 'active'?>" href="/hoi-dap">Hỏi đáp</a>
         </li>
         <li>
            <a class="<?php if($this->id == 'site' && $this->action->id == 'contact') echo 'active'?>" href="/lien-he">Liên hệ</a>
         </li>
         <li>
            <a class="post" href="/dang-tin">Đăng tin</a>
         </li>
         <li class="relative right btn-search">
            <i class="icon-search absolute sprite"></i>
            <div class="search-form absolute">
               <form class="form" id="form_search" method="GET" action="/tim-kiem">
                  <input class="searchfield" name="keyword" id="keyword" type="text" placeholder="Từ khóa" />
                  <input type="button" class="searchbutton" onclick="$('#form_search').submit()" value="Tìm kiếm" />
               </form>
            </div>
         </li>
      </ul>
   </div>
</div>
<script>
   $(document).ready(function(){
      $(".icon-search").click(function(){
         var __this = $(".btn-search");
         if(__this.hasClass('show-form-search')){
            __this.removeClass('show-form-search');
         }else{
            __this.addClass('show-form-search');
            $("#keyword").focus();
         }
      });
   });
   $(document).mouseup(function (e)
   {
       var container = $(".search-form");
       
       if (!container.is(e.target) // if the target of the click isn't the container...
           && container.has(e.target).length === 0) // ... nor a descendant of the container
       {
           $(".btn-search").removeClass('show-form-search');
       }
   });
</script>
